package com.taobao.tools;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.widgets.Widget;

import com.taobao.ui.widget.CommonWidget;

public class Binding {
	public static final String GROUP_TEXT = "Text";
	public static final String GROUP_LABEL_BUTTON = "LabelForButton";
    public static final String GROUP_CHECK = "Check";
    public static final String GROUP_COMBO = "Combo";
    public static final String GROUP_IMAGE = "LevelImage";
    public static final String GROUP_LIST_SIZE = "ListSize";
    public static final String GROUP_LIST = "List";
    private static Map<CommonWidget, List<Widget>> widgetMap = new HashMap<CommonWidget, List<Widget>>();
    private static Map<Widget, String> groupMap = new HashMap<Widget, String>();
    private static Map<Widget, Class<?>> pojoMap = new HashMap<Widget, Class<?>>();
	private static Map<Widget, String> pojoFieldMap = new HashMap<Widget, String>();

//	public static void binding(Widget widget, String widgetType, Class<?> pojoClass, String fieldName) {
//	    sourceMap.put(widget, widgetType);
//		targetMap.put(widget, pojoClass);
//		targetFieldMap.put(widget, fieldName);
//	}
	
	public static void binding(CommonWidget commonWidget, Widget widget, String widgetType, Class<?> pojoClass, String fieldName) {
		List<Widget> widgetList = widgetMap.get(commonWidget);
		if(widgetList == null){
			widgetList = new ArrayList<Widget>();
			widgetMap.put(commonWidget, widgetList);
		}
		widgetList.add(widget);
		groupMap.put(widget, widgetType);
		pojoMap.put(widget, pojoClass);
		pojoFieldMap.put(widget, fieldName);
	}

	public static Map<CommonWidget, List<Widget>> getBindingWidgets(){
		return widgetMap;
	}
	
	public static Map<Widget, String> getBindingGroup(){
		return groupMap;
	}
	
	public static Map<Widget, Class<?>> getBindingPojo(){
		return pojoMap;
	}
	
	public static Map<Widget, String> getBindingPojoField(){
		return pojoFieldMap;
	}
}
